home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / demos / a-d / blitzbasic21 / examples / blitzmode / doublebuffer.bb2 < prev    next >
Unknown  |  1995-09-18  |  2.2 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text


This file was not able to be converted.
This format is not currently supported by dexvert.

ConfidenceProgramDetectionMatch TypeSupport
100% file data default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 3b 00 3b 54 68 69 73 20 | 65 78 61 6d 70 6c 65 20 |;.;This |example |
|00000010| 64 65 6d 6f 6e 73 74 72 | 61 74 65 73 20 74 68 65 |demonstr|ates the|
|00000020| 20 70 72 69 6e 63 69 70 | 6c 65 20 62 65 68 69 6e | princip|le behin|
|00000030| 64 20 27 64 6f 75 62 6c | 65 20 62 75 66 66 65 72 |d 'doubl|e buffer|
|00000040| 69 6e 67 27 00 3b 00 3b | 44 6f 75 62 6c 65 20 62 |ing'.;.;|Double b|
|00000050| 75 66 66 65 72 69 6e 67 | 20 69 73 20 61 20 70 72 |uffering| is a pr|
|00000060| 6f 67 72 61 6d 6d 69 6e | 67 20 74 65 63 68 6e 69 |ogrammin|g techni|
|00000070| 71 75 65 20 61 6c 6c 6f | 77 69 6e 67 20 79 6f 75 |que allo|wing you|
|00000080| 00 3b 74 6f 20 67 65 74 | 20 72 69 64 20 6f 66 20 |.;to get| rid of |
|00000090| 27 66 6c 69 63 6b 65 72 | 27 20 66 72 6f 6d 20 67 |'flicker|' from g|
|000000a0| 72 61 70 68 69 63 20 61 | 6e 69 6d 61 74 69 6f 6e |raphic a|nimation|
|000000b0| 2e 00 3b 00 3b 44 6f 75 | 62 6c 65 20 62 75 66 66 |..;.;Dou|ble buff|
|000000c0| 65 72 69 6e 67 20 72 65 | 6c 69 65 73 20 6f 6e 20 |ering re|lies on |
|000000d0| 74 68 65 20 69 64 65 61 | 20 74 68 61 74 2c 20 61 |the idea| that, a|
|000000e0| 6c 74 68 6f 75 67 68 20 | 67 72 61 70 68 69 63 73 |lthough |graphics|
|000000f0| 00 3b 61 72 65 20 64 72 | 61 77 6e 20 74 6f 20 61 |.;are dr|awn to a|
|00000100| 20 70 61 72 74 69 63 75 | 6c 61 72 20 62 69 74 6d | particu|lar bitm|
|00000110| 61 70 2c 20 74 68 61 74 | 20 62 69 74 6d 61 70 20 |ap, that| bitmap |
|00000120| 6d 61 79 20 6e 6f 74 00 | 3b 6e 65 63 65 73 73 61 |may not.|;necessa|
|00000130| 72 69 6c 79 20 62 65 20 | 27 73 68 6f 77 6e 27 20 |rily be |'shown' |
|00000140| 6f 6e 20 74 68 65 20 64 | 69 73 70 6c 61 79 2e 00 |on the d|isplay..|
|00000150| 3b 00 3b 54 6f 20 61 63 | 68 69 65 76 65 20 64 6f |;.;To ac|hieve do|
|00000160| 75 62 6c 65 20 62 75 66 | 66 65 72 69 6e 67 2c 20 |uble buf|fering, |
|00000170| 79 6f 75 20 74 68 65 72 | 65 66 6f 72 65 20 6e 65 |you ther|efore ne|
|00000180| 65 64 20 61 74 20 6c 65 | 61 73 74 00 3b 32 20 62 |ed at le|ast.;2 b|
|00000190| 69 74 6d 61 70 73 2e 20 | 41 74 20 61 6e 79 20 6f |itmaps. |At any o|
|000001a0| 6e 65 20 70 6f 69 6e 74 | 20 69 6e 20 74 69 6d 65 |ne point| in time|
|000001b0| 2c 20 6f 6e 6c 79 20 31 | 20 6f 66 20 74 68 65 73 |, only 1| of thes|
|000001c0| 65 20 62 69 74 6d 61 70 | 73 00 3b 69 73 20 64 69 |e bitmap|s.;is di|
|000001d0| 73 70 6c 61 79 65 64 20 | 28 75 73 69 6e 67 20 6f |splayed |(using o|
|000001e0| 6e 65 20 6f 66 20 74 68 | 65 20 27 53 68 6f 77 27 |ne of th|e 'Show'|
|000001f0| 20 63 6f 6d 6d 61 6e 64 | 73 29 2c 20 77 68 69 6c | command|s), whil|
|00000200| 73 74 20 61 6e 79 00 3b | 67 72 61 70 68 69 63 20 |st any.;|graphic |
|00000210| 64 72 61 77 69 6e 67 20 | 69 73 20 70 65 72 66 6f |drawing |is perfo|
|00000220| 72 6d 65 64 20 6f 6e 20 | 54 48 45 20 4f 54 48 45 |rmed on |THE OTHE|
|00000230| 52 20 62 69 74 6d 61 70 | 2e 00 3b 44 75 72 69 6e |R bitmap|..;Durin|
|00000240| 67 20 74 68 65 20 76 65 | 72 74 69 63 61 6c 20 62 |g the ve|rtical b|
|00000250| 6c 61 6e 6b 20 70 65 72 | 69 6f 64 2c 20 74 68 65 |lank per|iod, the|
|00000260| 73 65 20 32 20 62 69 74 | 6d 61 70 73 20 61 72 65 |se 2 bit|maps are|
|00000270| 20 27 73 77 61 70 70 65 | 64 27 00 3b 69 65 20 2d | 'swappe|d'.;ie -|
|00000280| 20 74 68 65 20 6e 65 77 | 6c 79 20 75 70 64 61 74 | the new|ly updat|
|00000290| 65 64 20 62 69 74 6d 61 | 70 20 69 73 20 73 68 6f |ed bitma|p is sho|
|000002a0| 77 6e 2c 20 61 6e 64 20 | 74 68 65 20 70 72 65 76 |wn, and |the prev|
|000002b0| 69 6f 75 73 6c 79 00 3b | 73 68 6f 77 6e 20 62 69 |iously.;|shown bi|
|000002c0| 74 6d 61 70 20 69 73 20 | 75 73 65 64 20 66 6f 72 |tmap is |used for|
|000002d0| 20 74 68 65 20 6e 65 78 | 74 20 73 65 72 69 65 73 | the nex|t series|
|000002e0| 20 6f 66 20 75 70 64 61 | 74 65 73 21 00 00 00 3b | of upda|tes!...;|
|000002f0| 63 72 65 61 74 65 20 61 | 20 27 62 61 6c 6c 27 20 |create a| 'ball' |
|00000300| 74 79 70 65 20 76 61 72 | 69 61 62 6c 65 00 3b 00 |type var|iable.;.|
|00000310| 80 01 2e 62 61 6c 6c 00 | 78 2e 71 00 79 00 78 73 |...ball.|x.q.y.xs|
|00000320| 00 79 73 00 80 02 20 80 | 01 00 00 3b 64 69 6d 65 |.ys... .|...;dime|
|00000330| 6e 73 69 6f 6e 20 61 20 | 27 6c 69 73 74 27 20 6f |nsion a |'list' o|
|00000340| 66 20 27 62 61 6c 6c 73 | 27 00 3b 00 80 04 20 80 |f 'balls|'.;... .|
|00000350| b3 20 62 61 6c 6c 73 2e | 62 61 6c 6c 28 31 32 29 |. balls.|ball(12)|
|00000360| 00 00 3b 6c 6f 61 64 20 | 69 6e 20 61 20 73 68 61 |..;load |in a sha|
|00000370| 70 65 20 61 6e 64 20 69 | 74 27 73 20 70 61 6c 65 |pe and i|t's pale|
|00000380| 74 74 65 00 3b 00 cd 01 | 20 30 2c 22 64 61 74 61 |tte.;...| 0,"data|
|00000390| 2f 62 61 6c 6c 22 2c 30 | 00 00 3b 6b 65 65 70 20 |/ball",0|..;keep |
|000003a0| 61 64 64 69 6e 67 20 69 | 74 65 6d 73 20 74 6f 20 |adding i|tems to |
|000003b0| 6c 69 73 74 20 75 6e 74 | 69 6c 20 6c 69 73 74 20 |list unt|il list |
|000003c0| 66 75 6c 6c 00 3b 00 80 | 0c 20 c0 08 28 62 61 6c |full.;..|. ..(bal|
|000003d0| 6c 73 28 29 29 00 20 20 | 62 61 6c 6c 73 28 29 5c |ls()). |balls()\|
|000003e0| 78 3d bc 07 28 32 38 30 | 29 2b 31 30 2c bc 07 28 |x=..(280|)+10,..(|
|000003f0| 31 36 30 29 2b 31 30 2c | 28 bc 07 2d 2e 35 29 2a |160)+10,|(..-.5)*|
|00000400| 38 2c 28 bc 07 2d 2e 35 | 29 2a 38 00 80 c1 00 00 |8,(..-.5|)*8.....|
|00000410| 3b 6e 6f 77 2c 20 77 65 | 20 67 6f 20 69 6e 74 6f |;now, we| go into|
|00000420| 20 62 6c 69 74 7a 20 6d | 6f 64 65 00 3b 00 80 34 | blitz m|ode.;..4|
|00000430| 00 00 3b 69 6e 69 74 69 | 61 6c 69 7a 65 20 61 20 |..;initi|alize a |
|00000440| 6c 6f 72 2d 72 65 73 2c | 20 38 20 63 6f 6c 6f 75 |lor-res,| 8 colou|
|00000450| 72 20 62 69 74 6d 61 70 | 2e 2e 2e 00 3b 00 d0 01 |r bitmap|....;...|
|00000460| 20 30 2c 33 32 30 2c 32 | 30 30 2c 33 00 00 3b 77 | 0,320,2|00,3..;w|
|00000470| 65 20 61 6c 73 6f 20 6e | 65 65 64 20 61 6e 6f 74 |e also n|eed anot|
|00000480| 68 65 72 20 62 69 74 6d | 61 70 20 66 6f 72 20 74 |her bitm|ap for t|
|00000490| 68 65 20 64 6f 75 62 6c | 65 20 62 75 66 66 65 72 |he doubl|e buffer|
|000004a0| 69 6e 67 3a 00 3b 00 d0 | 01 20 31 2c 33 32 30 2c |ing:.;..|. 1,320,|
|000004b0| 32 30 30 2c 33 00 00 3b | 69 6e 69 74 69 61 6c 69 |200,3..;|initiali|
|000004c0| 7a 65 20 61 20 27 51 75 | 65 75 65 27 20 66 6f 72 |ze a 'Qu|eue' for|
|000004d0| 20 74 68 65 20 51 42 6c | 69 74 20 63 6f 6d 6d 61 | the QBl|it comma|
|000004e0| 6e 64 20 74 6f 20 6d 61 | 6b 65 20 75 73 65 20 6f |nd to ma|ke use o|
|000004f0| 66 3a 00 3b 00 ca 01 20 | 30 2c 35 30 00 00 3b 57 |f:.;... |0,50..;W|
|00000500| 65 20 77 69 6c 6c 20 61 | 6c 73 6f 20 64 6f 75 62 |e will a|lso doub|
|00000510| 6c 65 20 62 75 66 66 65 | 72 20 6f 75 72 20 71 75 |le buffe|r our qu|
|00000520| 65 75 65 27 73 2c 20 73 | 6f 20 77 65 20 6e 65 65 |eue's, s|o we nee|
|00000530| 64 20 61 6e 6f 74 68 65 | 72 00 3b 71 75 65 75 65 |d anothe|r.;queue|
|00000540| 3a 00 3b 00 ca 01 20 31 | 2c 35 30 00 00 3b 69 6e |:.;... 1|,50..;in|
|00000550| 69 74 69 61 6c 69 7a 65 | 20 61 20 73 6c 69 63 65 |itialize| a slice|
|00000560| 2c 20 61 6e 64 20 73 65 | 74 20 69 74 27 73 20 63 |, and se|t it's c|
|00000570| 6f 6c 6f 75 72 20 70 61 | 6c 65 74 74 65 00 3b 00 |olour pa|lette.;.|
|00000580| c7 82 20 30 2c 34 34 2c | 32 30 30 2c 33 2c 38 2c |.. 0,44,|200,3,8,|
|00000590| 38 2c 30 00 c7 86 20 30 | 2c 30 00 c7 84 20 30 2c |8,0... 0|,0... 0,|
|000005a0| 30 00 c7 83 20 30 00 00 | 3b 6e 6f 77 2c 20 70 72 |0... 0..|;now, pr|
|000005b0| 6f 63 65 73 73 20 61 6c | 6c 20 62 61 6c 6c 73 73 |ocess al|l ballss|
|000005c0| 2e 2e 2e 00 3b 00 3b 77 | 68 69 6c 65 20 6d 6f 75 |....;.;w|hile mou|
|000005d0| 73 65 20 62 75 74 74 6f | 6e 20 6e 6f 74 20 68 69 |se butto|n not hi|
|000005e0| 74 2e 2e 00 3b 00 80 0c | 20 df 04 28 30 29 3d 30 |t...;...| ..(0)=0|
|000005f0| 00 00 20 20 3b 73 74 61 | 72 74 20 61 74 20 66 69 |.. ;sta|rt at fi|
|00000600| 72 73 74 20 69 74 65 6d | 20 69 6e 20 6c 69 73 74 |rst item| in list|
|00000610| 00 20 20 3b 00 20 20 c0 | 04 20 62 61 6c 6c 73 28 |. ;. .|. balls(|
|00000620| 29 00 00 20 20 3b 77 61 | 69 74 20 66 6f 72 20 76 |).. ;wa|it for v|
|00000630| 65 72 74 69 63 61 6c 20 | 62 6c 61 6e 6b 00 20 20 |ertical |blank. |
|00000640| 3b 00 20 20 80 37 00 00 | 20 20 3b 74 68 69 73 20 |;. .7..| ;this |
|00000650| 62 69 74 20 64 6f 65 73 | 20 74 68 65 20 61 63 74 |bit does| the act|
|00000660| 75 61 6c 20 64 6f 75 62 | 6c 65 20 62 75 66 66 65 |ual doub|le buffe|
|00000670| 72 69 6e 67 3a 00 20 20 | 3b 74 68 65 20 27 64 62 |ring:. |;the 'db|
|00000680| 3d 31 2d 64 62 27 20 77 | 69 6c 6c 20 63 61 75 73 |=1-db' w|ill caus|
|00000690| 65 20 74 68 65 20 27 64 | 62 27 20 76 61 72 69 61 |e the 'd|b' varia|
|000006a0| 62 6c 65 20 74 6f 20 73 | 77 69 74 63 68 00 20 20 |ble to s|witch. |
|000006b0| 3b 62 65 74 77 65 65 6e | 20 30 2f 31 2f 30 2f 31 |;between| 0/1/0/1|
|000006c0| 2f 30 2f 31 2e 2e 2e 00 | 20 20 3b 00 20 20 c7 84 |/0/1....| ;. ..|
|000006d0| 20 30 2c 64 62 3a 64 62 | 3d 31 2d 64 62 3a 80 2c | 0,db:db|=1-db:.,|
|000006e0| 20 d0 01 20 64 62 00 00 | 20 20 3b 75 6e 71 75 65 | .. db..| ;unque|
|000006f0| 75 65 20 69 74 65 6d 73 | 20 6f 6e 20 74 68 65 20 |ue items| on the |
|00000700| 27 75 73 65 64 27 20 62 | 69 74 6d 61 70 3a 00 20 |'used' b|itmap:. |
|00000710| 20 3b 00 20 20 ca 03 20 | 64 62 00 00 20 20 3b 77 | ;. .. |db.. ;w|
|00000720| 68 69 6c 65 20 6d 6f 72 | 65 20 69 74 65 6d 73 20 |hile mor|e items |
|00000730| 74 6f 20 63 6f 6d 65 2e | 2e 2e 00 20 20 3b 00 20 |to come.|... ;. |
|00000740| 20 80 0c 20 c0 03 28 62 | 61 6c 6c 73 28 29 29 00 | .. ..(b|alls()).|
|00000750| 00 20 20 20 20 3b 75 70 | 64 61 74 65 20 62 61 6c |. ;up|date bal|
|00000760| 6c 73 27 20 70 6f 73 69 | 74 69 6f 6e 00 20 20 20 |ls' posi|tion. |
|00000770| 20 3b 00 20 20 20 20 62 | 61 6c 6c 73 28 29 5c 78 | ;. b|alls()\x|
|00000780| 2b 62 61 6c 6c 73 28 29 | 5c 78 73 00 20 20 20 20 |+balls()|\xs. |
|00000790| 62 61 6c 6c 73 28 29 5c | 79 2b 62 61 6c 6c 73 28 |balls()\|y+balls(|
|000007a0| 29 5c 79 73 00 00 20 20 | 20 20 3b 72 65 76 65 72 |)\ys.. | ;rever|
|000007b0| 73 65 20 64 69 72 65 63 | 74 69 6f 6e 20 69 66 20 |se direc|tion if |
|000007c0| 62 61 6c 6c 20 67 65 74 | 73 20 74 6f 20 65 64 67 |ball get|s to edg|
|000007d0| 65 20 6f 66 20 62 69 74 | 6d 61 70 00 20 20 20 20 |e of bit|map. |
|000007e0| 3b 00 20 20 20 20 80 0b | 20 62 61 6c 6c 73 28 29 |;. ..| balls()|
|000007f0| 5c 78 3c 31 30 20 80 8a | 20 62 61 6c 6c 73 28 29 |\x<10 ..| balls()|
|00000800| 5c 78 3e 32 39 30 20 80 | 21 20 62 61 6c 6c 73 28 |\x>290 .|! balls(|
|00000810| 29 5c 78 73 3d 2d 62 61 | 6c 6c 73 28 29 5c 78 73 |)\xs=-ba|lls()\xs|
|00000820| 00 20 20 20 20 80 0b 20 | 62 61 6c 6c 73 28 29 5c |. .. |balls()\|
|00000830| 79 3c 31 30 20 80 8a 20 | 62 61 6c 6c 73 28 29 5c |y<10 .. |balls()\|
|00000840| 79 3e 31 37 30 20 80 21 | 20 62 61 6c 6c 73 28 29 |y>170 .!| balls()|
|00000850| 5c 79 73 3d 2d 62 61 6c | 6c 73 28 29 5c 79 73 00 |\ys=-bal|ls()\ys.|
|00000860| 00 20 20 20 20 3b 64 72 | 61 77 20 62 61 6c 6c 73 |. ;dr|aw balls|
|00000870| 20 69 6e 20 6e 65 77 20 | 70 6f 73 69 74 69 6f 6e | in new |position|
|00000880| 00 20 20 20 20 3b 00 20 | 20 20 20 ca 02 20 64 62 |. ;. | .. db|
|00000890| 2c 30 2c 62 61 6c 6c 73 | 28 29 5c 78 2c 62 61 6c |,0,balls|()\x,bal|
|000008a0| 6c 73 28 29 5c 79 00 00 | 20 20 80 c1 00 80 c1 00 |ls()\y..| ......|
|000008b0| 00 80 02 00 | |.... | |
+--------+-------------------------+-------------------------+--------+--------+